<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>QuantumLibrary: Bloomberg::quantum::Mutex Class Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../navtreedata.js"></script>
<script type="text/javascript" src="../../navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">QuantumLibrary
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('../../',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('d7/d71/classBloomberg_1_1quantum_1_1Mutex.html','../../');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="../../d0/d81/classBloomberg_1_1quantum_1_1Mutex-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">Bloomberg::quantum::Mutex Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Coroutine-compatible implementation of a mutex.  
 <a href="../../d7/d71/classBloomberg_1_1quantum_1_1Mutex.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="../../dc/d3d/quantum__mutex_8h_source.html">quantum_mutex.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/dbb/classBloomberg_1_1quantum_1_1Mutex_1_1Guard.html">Guard</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d4/d39/classBloomberg_1_1quantum_1_1Mutex_1_1ReverseGuard.html">ReverseGuard</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:aea33990f2e839eefc1939f5b1c296e5e"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d7/d71/classBloomberg_1_1quantum_1_1Mutex.html#aea33990f2e839eefc1939f5b1c296e5e">Mutex</a> ()</td></tr>
<tr class="memdesc:aea33990f2e839eefc1939f5b1c296e5e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Default constructor.  <a href="#aea33990f2e839eefc1939f5b1c296e5e">More...</a><br /></td></tr>
<tr class="separator:aea33990f2e839eefc1939f5b1c296e5e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aca651f127056f6772790aac37f952802"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d7/d71/classBloomberg_1_1quantum_1_1Mutex.html#aca651f127056f6772790aac37f952802">Mutex</a> (const <a class="el" href="../../d7/d71/classBloomberg_1_1quantum_1_1Mutex.html">Mutex</a> &amp;other)=delete</td></tr>
<tr class="separator:aca651f127056f6772790aac37f952802"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adb113121919a992c6819b7cdaa5dff85"><td class="memItemLeft" align="right" valign="top"><a class="el" href="../../d7/d71/classBloomberg_1_1quantum_1_1Mutex.html">Mutex</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d7/d71/classBloomberg_1_1quantum_1_1Mutex.html#adb113121919a992c6819b7cdaa5dff85">operator=</a> (const <a class="el" href="../../d7/d71/classBloomberg_1_1quantum_1_1Mutex.html">Mutex</a> &amp;other)=delete</td></tr>
<tr class="separator:adb113121919a992c6819b7cdaa5dff85"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1872a5c36145280c97610b06a14cc946"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d7/d71/classBloomberg_1_1quantum_1_1Mutex.html#a1872a5c36145280c97610b06a14cc946">lock</a> ()</td></tr>
<tr class="memdesc:a1872a5c36145280c97610b06a14cc946"><td class="mdescLeft">&#160;</td><td class="mdescRight">Locks this mutex.  <a href="#a1872a5c36145280c97610b06a14cc946">More...</a><br /></td></tr>
<tr class="separator:a1872a5c36145280c97610b06a14cc946"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5224f6b74c7c422e18e7d9134aae3489"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d7/d71/classBloomberg_1_1quantum_1_1Mutex.html#a5224f6b74c7c422e18e7d9134aae3489">lock</a> (<a class="el" href="../../d3/d63/structBloomberg_1_1quantum_1_1ICoroSync.html#a109b2c4b7d70d53d48bb640a9d849b29">ICoroSync::Ptr</a> sync)</td></tr>
<tr class="memdesc:a5224f6b74c7c422e18e7d9134aae3489"><td class="mdescLeft">&#160;</td><td class="mdescRight">Locks this mutex.  <a href="#a5224f6b74c7c422e18e7d9134aae3489">More...</a><br /></td></tr>
<tr class="separator:a5224f6b74c7c422e18e7d9134aae3489"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0cc992ecc63c035190fd00738a06a79c"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d7/d71/classBloomberg_1_1quantum_1_1Mutex.html#a0cc992ecc63c035190fd00738a06a79c">tryLock</a> ()</td></tr>
<tr class="memdesc:a0cc992ecc63c035190fd00738a06a79c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Tries to lock the mutex object.  <a href="#a0cc992ecc63c035190fd00738a06a79c">More...</a><br /></td></tr>
<tr class="separator:a0cc992ecc63c035190fd00738a06a79c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af9236a39187a7bfab8a86960c0c2d562"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d7/d71/classBloomberg_1_1quantum_1_1Mutex.html#af9236a39187a7bfab8a86960c0c2d562">unlock</a> ()</td></tr>
<tr class="memdesc:af9236a39187a7bfab8a86960c0c2d562"><td class="mdescLeft">&#160;</td><td class="mdescRight">Unlock this mutex.  <a href="#af9236a39187a7bfab8a86960c0c2d562">More...</a><br /></td></tr>
<tr class="separator:af9236a39187a7bfab8a86960c0c2d562"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Coroutine-compatible implementation of a mutex. </p>
<p>This mutex wraps a specialized form of spinlock. The mutex must be used to protect a critical region which is shared between coroutines and (optionally) other code running in a non-coroutine (i.e. regular threaded) context. </p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="aea33990f2e839eefc1939f5b1c296e5e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aea33990f2e839eefc1939f5b1c296e5e">&#9670;&nbsp;</a></span>Mutex() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">Bloomberg::quantum::Mutex::Mutex </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Default constructor. </p>
<dl class="section note"><dt>Note</dt><dd><a class="el" href="../../d7/d71/classBloomberg_1_1quantum_1_1Mutex.html" title="Coroutine-compatible implementation of a mutex.">Mutex</a> object is in unlocked state. </dd></dl>

</div>
</div>
<a id="aca651f127056f6772790aac37f952802"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aca651f127056f6772790aac37f952802">&#9670;&nbsp;</a></span>Mutex() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">Bloomberg::quantum::Mutex::Mutex </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="../../d7/d71/classBloomberg_1_1quantum_1_1Mutex.html">Mutex</a> &amp;&#160;</td>
          <td class="paramname"><em>other</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">delete</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a1872a5c36145280c97610b06a14cc946"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1872a5c36145280c97610b06a14cc946">&#9670;&nbsp;</a></span>lock() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Bloomberg::quantum::Mutex::lock </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Locks this mutex. </p>
<p>The mutex object yields (or conditionally sleeps) the current thread for a short period of time until locking succeeds. See <a class="el" href="../../dd/d4a/structBloomberg_1_1quantum_1_1YieldingThreadDuration.html" title="This class provides the same functionality as a coroutine yield when called from a thread context.">YieldingThreadDuration</a> for more details. </p><dl class="section note"><dt>Note</dt><dd>Must be called in a non-coroutine context. </dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>Wrongfully calling this method from a coroutine will block all coroutines running in the same queue and thus result in noticeable performance degradation. </dd></dl>

</div>
</div>
<a id="a5224f6b74c7c422e18e7d9134aae3489"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5224f6b74c7c422e18e7d9134aae3489">&#9670;&nbsp;</a></span>lock() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Bloomberg::quantum::Mutex::lock </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="../../d3/d63/structBloomberg_1_1quantum_1_1ICoroSync.html#a109b2c4b7d70d53d48bb640a9d849b29">ICoroSync::Ptr</a>&#160;</td>
          <td class="paramname"><em>sync</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Locks this mutex. </p>
<p>The mutex object yields the current coroutine until locking succeeds. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">sync</td><td>Pointer to a coroutine synchronization object. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>Must be called from a coroutine. </dd></dl>

</div>
</div>
<a id="adb113121919a992c6819b7cdaa5dff85"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adb113121919a992c6819b7cdaa5dff85">&#9670;&nbsp;</a></span>operator=()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="../../d7/d71/classBloomberg_1_1quantum_1_1Mutex.html">Mutex</a>&amp; Bloomberg::quantum::Mutex::operator= </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="../../d7/d71/classBloomberg_1_1quantum_1_1Mutex.html">Mutex</a> &amp;&#160;</td>
          <td class="paramname"><em>other</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">delete</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<a id="a0cc992ecc63c035190fd00738a06a79c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0cc992ecc63c035190fd00738a06a79c">&#9670;&nbsp;</a></span>tryLock()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool Bloomberg::quantum::Mutex::tryLock </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Tries to lock the mutex object. </p>
<dl class="section return"><dt>Returns</dt><dd>True if succeeds, false otherwise. </dd></dl>

</div>
</div>
<a id="af9236a39187a7bfab8a86960c0c2d562"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af9236a39187a7bfab8a86960c0c2d562">&#9670;&nbsp;</a></span>unlock()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Bloomberg::quantum::Mutex::unlock </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Unlock this mutex. </p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="../../d6/db9/namespaceBloomberg.html">Bloomberg</a></li><li class="navelem"><a class="el" href="../../dc/d48/namespaceBloomberg_1_1quantum.html">quantum</a></li><li class="navelem"><a class="el" href="../../d7/d71/classBloomberg_1_1quantum_1_1Mutex.html">Mutex</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="../../doxygen.png" alt="doxygen"/></a> 1.8.15 </li>
  </ul>
</div>
</body>
</html>
